/*
 * frmPrincipal.java
 *
 * Created on 03/11/2011, 11:44:19
 */
package scc.Telas;

import scc.Dao.UserDAO;
import scc.Entidade.Usuario;
import java.beans.PropertyVetoException;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JInternalFrame;
/**
 *
 * @author Davidson
 */
public class frmPrincipal extends javax.swing.JFrame {
        
    private JInternalFrame janelaInternaManutUsuario;
    private JInternalFrame janelaInternaAbrirCaixa;
    private UserDAO dao;
    private Usuario usuario;
    /** Creates new form frmPrincipal */
    public frmPrincipal(UserDAO dao2, Usuario usuario2) {
        initComponents();
        dao = dao2;
        usuario = usuario2;        
        this.setExtendedState(MAXIMIZED_BOTH);
        //this.setIconImage(new javax.swing.ImageIcon(getClass().getResource("/scc/Imagens/currency_dollar_red.png")).getImage());
    }   

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDesktop = new javax.swing.JDesktopPane();
        mbPrincipal = new javax.swing.JMenuBar();
        mnCaixa = new javax.swing.JMenu();
        miCadastrarMembros = new javax.swing.JMenuItem();
        mnManutencao = new javax.swing.JMenu();
        miManutUsuarios = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("CONTROLM - Controle de Membros da AD Vale da Simpatia");
        setIconImages(null);

        jDesktop.setBackground(new java.awt.Color(255, 255, 255));

        mbPrincipal.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        mbPrincipal.setMaximumSize(new java.awt.Dimension(170, 40));
        mbPrincipal.setMinimumSize(new java.awt.Dimension(170, 40));
        mbPrincipal.setPreferredSize(new java.awt.Dimension(170, 38));

        mnCaixa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/scc/Imagens/pasta_arquivo.png"))); // NOI18N
        mnCaixa.setText("Cadastro de Membros");
        mnCaixa.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        mnCaixa.setMargin(new java.awt.Insets(1, 4, 1, 1));
        mnCaixa.setMaximumSize(new java.awt.Dimension(170, 70));
        mnCaixa.setPreferredSize(new java.awt.Dimension(170, 70));

        miCadastrarMembros.setIcon(new javax.swing.ImageIcon(getClass().getResource("/scc/Imagens/pessoas.png"))); // NOI18N
        miCadastrarMembros.setText("Cadastrar Membros");
        miCadastrarMembros.setPreferredSize(new java.awt.Dimension(191, 38));
        miCadastrarMembros.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miCadastrarMembrosActionPerformed(evt);
            }
        });
        mnCaixa.add(miCadastrarMembros);

        mbPrincipal.add(mnCaixa);

        mnManutencao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/scc/Imagens/Settings.png"))); // NOI18N
        mnManutencao.setText("Manutenção");
        mnManutencao.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        mnManutencao.setMargin(new java.awt.Insets(1, 1, 1, 1));
        mnManutencao.setMaximumSize(new java.awt.Dimension(120, 70));
        mnManutencao.setPreferredSize(new java.awt.Dimension(120, 70));

        miManutUsuarios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/scc/Imagens/password.png"))); // NOI18N
        miManutUsuarios.setText("Manutenção de Usuários");
        miManutUsuarios.setOpaque(true);
        miManutUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miManutUsuariosActionPerformed(evt);
            }
        });
        mnManutencao.add(miManutUsuarios);

        mbPrincipal.add(mnManutencao);

        setJMenuBar(mbPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktop, javax.swing.GroupLayout.DEFAULT_SIZE, 778, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktop, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void miManutUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miManutUsuariosActionPerformed
        
        janelaInternaManutUsuario = frmManutencaoDeUsuarios.getInstancia(dao, usuario);
        if (janelaInternaManutUsuario.getParent() != jDesktop) {
                jDesktop.add(janelaInternaManutUsuario);
        }
        janelaInternaManutUsuario.show();
        janelaInternaManutUsuario.moveToFront();

    }//GEN-LAST:event_miManutUsuariosActionPerformed

    private void miCadastrarMembrosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miCadastrarMembrosActionPerformed
        try {                                             
            
            janelaInternaAbrirCaixa = FrmCadastrarMembros.getInstancia(dao, usuario);
            if (janelaInternaAbrirCaixa.getParent() != jDesktop) jDesktop.add(janelaInternaAbrirCaixa);            
            janelaInternaAbrirCaixa.show();
            janelaInternaAbrirCaixa.moveToFront();
            janelaInternaAbrirCaixa.setMaximum(false);            
        } catch (ParseException ex) {
            Logger.getLogger(frmPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (PropertyVetoException ex) {
            Logger.getLogger(frmPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(frmPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_miCadastrarMembrosActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane jDesktop;
    private javax.swing.JMenuBar mbPrincipal;
    private javax.swing.JMenuItem miCadastrarMembros;
    private javax.swing.JMenuItem miManutUsuarios;
    private javax.swing.JMenu mnCaixa;
    private javax.swing.JMenu mnManutencao;
    // End of variables declaration//GEN-END:variables

}